{% set pypi_name = 'tooz' %}
{% set upstream_version = upstream_version('2.8.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

%if 0%{?rhel} || 0%{?fedora}
%global rdo 1
%endif
Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        Coordination library for distributed systems
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/tooz/latest/
Source0:        {{ source }}
BuildRequires:  memcached
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('fasteners') }}
BuildRequires:  {{ py3('fixtures') }}
BuildRequires:  {{ py3('futurist') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('oslo.serialization') }}
BuildRequires:  {{ py3('oslo.utils') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('pymemcache') }}
BuildRequires:  {{ py3('stevedore') }}
BuildRequires:  {{ py3('tenacity') }}
BuildRequires:  {{ py3('testtools') }}
BuildRequires:  {{ py3('voluptuous') }}
BuildArch:      noarch
%if ! 0%{?rdo}
BuildRequires:  {{ py3('pifpaf') }}
%endif

%description
The Tooz project aims at centralizing the most common distributed primitives
like group membership protocol, lock service and leader election by providing
a coordination API helping developers to build distributed applications.

%package -n python3-tooz
Summary:        Coordination library for distributed systems
Requires:       {{ py3('fasteners') }}
Requires:       {{ py3('futurist') }}
Requires:       {{ py3('msgpack') }}
Requires:       {{ py3('oslo.serialization') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('six') }}
Requires:       {{ py3('stevedore') }}
Requires:       {{ py3('tenacity') }}
Requires:       {{ py3('voluptuous') }}

%description -n python3-tooz
The Tooz project aims at centralizing the most common distributed primitives
like group membership protocol, lock service and leader election by providing
a coordination API helping developers to build distributed applications.

This package contains the Python 3.x module.

%package -n python-tooz-doc
Summary:        Documentation for %{name}
Group:          Documentation/HTML
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}

%description  -n python-tooz-doc
The Tooz project aims at centralizing the most common distributed primitives
like group membership protocol, lock service and leader election by providing
a coordination API helping developers to build distributed applications.

This package contains documentation in HTML format.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%{py3_build}

# generate html docs
PYTHONPATH=. \
    %sphinx_build -b html doc/source doc/build/html
# remove the Sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%check
%if ! 0%{?rdo}
export TOOZ_TEST_DRIVERS="memcached"
export PATH=%{_prefix}/sbin:$PATH
export LC_ALL=en_US.UTF-8
bash run-tests.sh
%endif

%install
%{py3_install}

%files -n python3-tooz
%license LICENSE
%{python3_sitelib}/{{ pypi_name }}
%{python3_sitelib}/{{ pypi_name }}-*.egg-info

%files -n python-tooz-doc
%license LICENSE
%doc doc/build/html README.rst

%changelog
